package com.horsecoder.im.common.protocol.convert.support;

import com.horsecoder.im.common.protocol.context.chain.request.Request;
import com.horsecoder.im.common.protocol.context.chain.response.Response;
import com.horsecoder.im.common.protocol.convert.Converter;

/**
 * Author: Zhu yuhan
 * Email: zhuyuhan2333@qq.com
 * Date: 2022/3/16 11:23 上午
 **/
public class RequestResponseConverter implements Converter<Request, Response> {

    @Override
    public Response convert(Request request) {
        Response response = new Response(request);
        response.setReceiver(request.getReceiver());
        response.setMessage(request.getMessage());
        response.setTransferType(request.getTransferType());
        response.setUrl(request.getUrl());
        response.setType(request.getType());
        response.setIdentity(request.getIdentity());
        return response;
    }

    public static void convert(Request request, Response response) {
        response.setRequest(request);
        response.setReceiver(request.getReceiver());
        response.setMessage(request.getMessage());
        response.setTransferType(request.getTransferType());
        response.setUrl(request.getUrl());
        response.setType(request.getType());
        response.setIdentity(request.getIdentity());
    }
}
